package com.sy.service.impl;

import com.sy.entity.Subject;
import com.sy.exception.BusinessException;
import com.sy.mapper.SubjectMapper;
import com.sy.service.SubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

/**
 * description: SubjectServiceImpl <br>
 * date: 2022/6/28 3:21 PM <br>
 * author: zoumaoji <br>
 * version: 1.0 <br>
 */
@Service
public class SubjectServiceImpl extends AbstractBaseServiceImpl implements SubjectService {
    @Autowired
    private SubjectMapper subjectMapper;

    @Override
    public List<Subject> selectAllSubject() {
        return subjectMapper.selectAllSubject();
    }

    @Override
    public Subject getSubjectById(Integer subjectId) {
        if (Objects.isNull(subjectId)){
            throw new BusinessException(HttpStatus.BAD_REQUEST,"课程id为空");
        }
        return subjectMapper.getSubjectById(subjectId);
    }
}
